package com.ssm.controller;

import com.ssm.service.AllNumberService;
import net.sf.json.JSON;
import net.sf.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;
@CrossOrigin
@RequestMapping(value = "allnumber")
@Controller
public class AllNumberController {

    @Autowired
    public AllNumberService allNumberService;
    public void setAllNumberService(AllNumberService allNumberService) {
        this.allNumberService = allNumberService;
    }

    @ResponseBody
    @RequestMapping(value = "all")
    public JSON allNumberList(@RequestParam("address") String address){
        int allNumber = this.allNumberService.countAllNum(address);
//        List<Integer> num = new ArrayList<Integer>();
//        num.add(allNumber);
        Map map = new HashMap();
        map.put("allNumber",allNumber);
        JSONObject jsonObject = JSONObject.fromObject(map);
        return jsonObject;

    }
}
